﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DelonixRegiaHMSys.Core.Services;
using DelonixRegiaHMSys.Infrastructure.Data;
using DelonixRegiaHMSys.Core.Models;

namespace DelonixRegiaHMSys.UI.WebForms
{
    public partial class UpdateStaff : System.Web.UI.Page
    {
        string userID;
        protected void Page_Load(object sender, EventArgs e)
        {
            userID = Request.QueryString["UserID"];
            if (!IsPostBack)
            {
                Staff.Text = Request.QueryString["Staff"];
                StaffImage.Text = Request.QueryString["StaffImage"];
                LastName.Text = Request.QueryString["StaffLastName"];
                FirstName.Text = Request.QueryString["StaffFirstName"];
                DOBtbx.Text = Request.QueryString["DOB"];
                BankAcc.Text = Request.QueryString["BankAccNum"];
                Add.Text = Request.QueryString["HomeAdd"];
                PhoneNo.Text = Request.QueryString["PhoneNum"];
                Duties.SelectedValue = Request.QueryString["DutiesName"];
            }
        }

        protected void Updatebtn_Click(object sender, EventArgs e)
        {
            Staff st = new Staff();
            st.StaffID = Staff.Text;
            st.StaffLastName = LastName.Text;
            st.StaffFirstName = FirstName.Text;
            st.DateOfBirth = Convert.ToDateTime(DOBtbx.Text);
            st.BankAccNum = BankAcc.Text;
            st.HomeAddress = Add.Text;
            st.PhoneNum = Convert.ToInt32(PhoneNo.Text);
            st.DutiesName = Duties.SelectedValue;

            var sservice = new stServices(new EfStaffQuery());
            sservice.UpdateStaff(st);

            Server.Transfer("~/WebForms/HousekeepingandStaffModule/StaffManagement.aspx?UserID=" + userID);
        }
    }
}